{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 99,
   "id": "be613582",
   "metadata": {},
   "outputs": [],
   "source": [
    "import requests"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 100,
   "id": "f9b4d8f9",
   "metadata": {},
   "outputs": [],
   "source": [
    "base_url = 'https://api-cn.faceplusplus.com/facepp/v3/detect'\n",
    "\n",
    "API_key = 'LukyQeR7qLZ7J7Ue8wTFsZ1L4SVnjj8n'\n",
    "API_sercret = 'ztjVZ14dTNspk2nfrW0rc0f-qGVGUPQM'\n",
    "\n",
    "payload = {\n",
    "    'api_key':API_key,\n",
    "    'api_secret':API_sercret,\n",
    "    'image_url':'http://5b0988e595225.cdn.sohucs.com/images/20180902/a6d1eda672264bc6b464ccf3322c3b0a.jpeg'\n",
    "}\n",
    "\n",
    "r_01 = requests.post(base_url, params = payload)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 101,
   "id": "e4da4715",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Response [200]>"
      ]
     },
     "execution_count": 101,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r_01"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 102,
   "id": "337fecbf",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'request_id': '1648561212,c16884d9-9cc8-4d11-9d13-6df00fcdd2fd',\n",
       " 'time_used': 149,\n",
       " 'faces': [{'face_token': '5b0e2e2de139e145e9588ecd6a230b81',\n",
       "   'face_rectangle': {'top': 127, 'left': 277, 'width': 103, 'height': 103}}],\n",
       " 'image_id': 'IWRjjSWiS+NTordz49UfsA==',\n",
       " 'face_num': 1}"
      ]
     },
     "execution_count": 102,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r_01.json()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 103,
   "id": "43498426",
   "metadata": {},
   "outputs": [],
   "source": [
    "base_url = 'https://api-cn.faceplusplus.com/facepp/v3/detect'\n",
    "\n",
    "API_key = 'LukyQeR7qLZ7J7Ue8wTFsZ1L4SVnjj8n'\n",
    "API_sercret = 'ztjVZ14dTNspk2nfrW0rc0f-qGVGUPQM'\n",
    "\n",
    "payload = {\n",
    "    'api_key':API_key,\n",
    "    'api_secret':API_sercret,\n",
    "    'image_url':'http://5b0988e595225.cdn.sohucs.com/images/20180902/a6d1eda672264bc6b464ccf3322c3b0a.jpeg'    \n",
    "}\n",
    "\n",
    "r_02 = requests.post(base_url, params = payload)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 104,
   "id": "8ce53c03",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Response [200]>"
      ]
     },
     "execution_count": 104,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r_02"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 105,
   "id": "03f37228",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'request_id': '1648561212,1f4f3395-620f-43d4-a188-e019b2677553',\n",
       " 'time_used': 90,\n",
       " 'faces': [{'face_token': 'fc1e75072f4ba84c876d831f1f16f305',\n",
       "   'face_rectangle': {'top': 127, 'left': 277, 'width': 103, 'height': 103}}],\n",
       " 'image_id': 'IWRjjSWiS+NTordz49UfsA==',\n",
       " 'face_num': 1}"
      ]
     },
     "execution_count": 105,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r_02.json()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 106,
   "id": "6fc043f4",
   "metadata": {},
   "outputs": [],
   "source": [
    "base_url = 'https://api-cn.faceplusplus.com/facepp/v3/detect'\n",
    "\n",
    "API_key = 'LukyQeR7qLZ7J7Ue8wTFsZ1L4SVnjj8n'\n",
    "API_sercret = 'ztjVZ14dTNspk2nfrW0rc0f-qGVGUPQM'\n",
    "\n",
    "payload = {\n",
    "    'api_key':API_key,\n",
    "    'api_secret':API_sercret,\n",
    "    'image_url':'http://5b0988e595225.cdn.sohucs.com/images/20180902/a6d1eda672264bc6b464ccf3322c3b0a.jpeg'    \n",
    "}\n",
    "\n",
    "r_03 = requests.post(base_url, params = payload)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 107,
   "id": "ba2cb3e4",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Response [200]>"
      ]
     },
     "execution_count": 107,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r_03"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 108,
   "id": "12817470",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'request_id': '1648561213,2e818b9a-a8ac-4309-b7e7-1ed5c8111d56',\n",
       " 'time_used': 75,\n",
       " 'faces': [{'face_token': 'b640569d3f71015b4f6c8754e1cfa026',\n",
       "   'face_rectangle': {'top': 127, 'left': 277, 'width': 103, 'height': 103}}],\n",
       " 'image_id': 'IWRjjSWiS+NTordz49UfsA==',\n",
       " 'face_num': 1}"
      ]
     },
     "execution_count": 108,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r_03.json()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 109,
   "id": "c62c5e3c",
   "metadata": {},
   "outputs": [],
   "source": [
    "base_url = 'https://api-cn.faceplusplus.com/facepp/v3/detect'\n",
    "\n",
    "API_key = 'LukyQeR7qLZ7J7Ue8wTFsZ1L4SVnjj8n'\n",
    "API_sercret = 'ztjVZ14dTNspk2nfrW0rc0f-qGVGUPQM'\n",
    "\n",
    "payload = {\n",
    "    'api_key':API_key,\n",
    "    'api_secret':API_sercret,\n",
    "    'image_url':'http://5b0988e595225.cdn.sohucs.com/images/20180902/a6d1eda672264bc6b464ccf3322c3b0a.jpeg'    \n",
    "}\n",
    "\n",
    "r_04 = requests.post(base_url, params = payload)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 110,
   "id": "a162e8ec",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Response [200]>"
      ]
     },
     "execution_count": 110,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r_04"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 111,
   "id": "aec63918",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'request_id': '1648561214,db3d9315-6b37-4128-b41f-0f71ca08de2b',\n",
       " 'time_used': 114,\n",
       " 'faces': [{'face_token': '93436e59a5d3442a7f97c9aafcce1ca4',\n",
       "   'face_rectangle': {'top': 127, 'left': 277, 'width': 103, 'height': 103}}],\n",
       " 'image_id': 'IWRjjSWiS+NTordz49UfsA==',\n",
       " 'face_num': 1}"
      ]
     },
     "execution_count": 111,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r_04.json()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 112,
   "id": "9cef61f9",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 113,
   "id": "50309f3d",
   "metadata": {},
   "outputs": [],
   "source": [
    "import requests\n",
    "API_key = 'LukyQeR7qLZ7J7Ue8wTFsZ1L4SVnjj8n'\n",
    "API_sercret = 'ztjVZ14dTNspk2nfrW0rc0f-qGVGUPQM'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 116,
   "id": "b263ed8b",
   "metadata": {},
   "outputs": [
    {
     "ename": "SyntaxError",
     "evalue": "EOL while scanning string literal (<ipython-input-116-0d822726a830>, line 7)",
     "output_type": "error",
     "traceback": [
      "\u001b[1;36m  File \u001b[1;32m\"<ipython-input-116-0d822726a830>\"\u001b[1;36m, line \u001b[1;32m7\u001b[0m\n\u001b[1;33m    '\u001b[0m\n\u001b[1;37m     ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m EOL while scanning string literal\n"
     ]
    }
   ],
   "source": [
    "FaceSet_C_url = 'https://api-cn.faceplusplus.com/facepp/v3/faceset/create'\n",
    "payload = {\n",
    "    'api_key':API_key,\n",
    "    'api_secret':API_sercret,\n",
    "    'display_name':'T4T',\n",
    "    'face_tokens':'5b0e2e2de139e145e9588ecd6a230b81,fc1e75072f4ba84c876d831f1f16f305,b640569d3f71015b4f6c8754e1cfa026,93436e59a5d3442a7f97c9aafcce1ca4'\n",
    "'\n",
    "    'user_data':'4人'\n",
    "}\n",
    "r_create = requests.post(url = FaceSet_C_url, params = payload)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 117,
   "id": "210ecae9",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Response [400]>"
      ]
     },
     "execution_count": 117,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r_create"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 118,
   "id": "82fa1449",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'time_used': 80,\n",
       " 'error_message': 'FACESET_EXIST',\n",
       " 'request_id': '1648558289,2b925dff-61c6-4fed-a7b3-159b950cd68e'}"
      ]
     },
     "execution_count": 118,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r_create.json()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 119,
   "id": "66c6091c",
   "metadata": {},
   "outputs": [],
   "source": [
    "Getdetail_url = \"https://api-cn.faceplusplus.com/facepp/v3/faceset/getdetail\"\n",
    "payload = {\n",
    "    'api_key':API_key,\n",
    "    'api_secret':API_sercret,\n",
    "    'faceset_token':'daf37a79b38dd621290f34bf7d40f491'\n",
    "}\n",
    "r_getdetail = requests.post(url = Getdetail_url, params = payload)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 120,
   "id": "23587079",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Response [400]>"
      ]
     },
     "execution_count": 120,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r_getdetail"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 121,
   "id": "7600371a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'time_used': 56,\n",
       " 'error_message': 'INVALID_FACESET_TOKEN',\n",
       " 'request_id': '1648561353,9a33d805-6340-4a13-884b-a938f576baf3'}"
      ]
     },
     "execution_count": 121,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r_getdetail.json()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 122,
   "id": "5fe5aff1",
   "metadata": {},
   "outputs": [],
   "source": [
    "import requests\n",
    "API_key = 'fNEU2hYREvIGyzyWcAtTkLIMLUcU2CIR'\n",
    "API_sercret = '0sCiSU3LIeAbUfYCHb2I695DoO0xea4I'\n",
    "\n",
    "Search_url = 'https://api-cn.faceplusplus.com/facepp/v3/search'\n",
    "payload = {\n",
    "    'api_key':API_key,\n",
    "    'api_secret':API_sercret,\n",
    "    'image_url':'https://wx3.sinaimg.cn/mw2000/006jfIhWly1gzz4sh7r64j33gg56ox6v.jpg',\n",
    "    'faceset_token':'daf37a79b38dd621290f34bf7d40f491'\n",
    "}\n",
    "r_search = requests.post(url = Search_url, params = payload)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 123,
   "id": "c772a857",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Response [200]>"
      ]
     },
     "execution_count": 123,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r_search"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 124,
   "id": "fe52a25e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'image_id': 'a6Q8G22+NOCgMa++3HBD1Q==',\n",
       " 'faces': [{'face_rectangle': {'width': 451,\n",
       "    'top': 901,\n",
       "    'left': 495,\n",
       "    'height': 451},\n",
       "   'face_token': 'c728dbb648b5939486a0cb45c2deb0f5'}],\n",
       " 'time_used': 1677,\n",
       " 'thresholds': {'1e-3': 62.327, '1e-5': 73.975, '1e-4': 69.101},\n",
       " 'request_id': '1648561355,27061a8f-4f5a-488f-b22d-75e661a6118e',\n",
       " 'results': [{'confidence': 90.374,\n",
       "   'user_id': '',\n",
       "   'face_token': 'ccdd49bd6a960dd41fb3ba21c4f64e1a'}]}"
      ]
     },
     "execution_count": 124,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r_search.json()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "237d47ce",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
